package com.deyuanyun.pic.settings.support.validateFunc;

import com.deyuanyun.pic.common.validator.vinterface.ValidateInterface;
import java.util.HashMap;
import java.util.Map;

import com.deyuanyun.pic.common.spring.SpringAppliction;
import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.validator.vinterface.ValidateInterface;
import com.deyuanyun.pic.settings.domain.prvlg.User;
import com.deyuanyun.pic.settings.mapper.prvlg.UserMapper;

public class EmailValidata implements ValidateInterface {

	@Override
	public <T, E, C> boolean apply(T t, E e, C c) {
		boolean flag = true;
		if (ObjectUtil.isNotNullEmpty(t)) {
			UserMapper um = SpringAppliction.getBean(UserMapper.class);
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("email", (String) t.toString());
			map.put("userId", "");
			User u = um.selectUserByEmail(map);
			if (ObjectUtil.isNotNullEmpty(u)) {
				flag = false;
			}
		}
		return flag;
	}

	@Override
	public String getName() {
		return null;
	}

}
